<template>
  <div class="user_overview">
    <div style="color: #07f7a8;">
      <div class="user_overview_nums online">
        <dv-digital-flop :config="todayready" style="width:100%;height:100%;" />
      </div>
      <p>今日险情数</p>
    </div>
    <div style="color: #e3b337;">
      <div class="user_overview_nums offline">
        <dv-digital-flop :config="todaywarn" style="width:100%;height:100%;" />
      </div>
      <p>今日预警次数</p>
    </div>
    <div style="color: #e33737;">
      <div class="user_overview_nums laramnum">
        <dv-digital-flop :config="monthwarn" style="width:100%;height:100%;" />
      </div>
      <p>本月预警次数</p>
    </div>
  </div>
</template>

<script setup lang="ts">
import {digital} from '@/api/swimming/plan/index'
let today = reactive({
    number: [0],
    style: {
        fill: '#00fdfa',
    }
})
let todayready = reactive({
    number: [32],
    style: {
        fill: '#07f7a8',
    }
})
const todaywarn = reactive({
    number: [6],
    style: {
        fill: '#e3b337',
    }
})
const monthwarn = reactive({
    number: [123],
    style: {
        fill: '#e33737',
    }
})

const getData=async()=>{
    var res=await digital()

    today.number[0]=res.data['swim']
    todayready.number=[res.data['ready']]
}
onMounted(()=>{
    getData()
})

const intervalId = setInterval(()=>{
  getData()
},1000)

onUnmounted(()=>{
  clearInterval(intervalId)
})
</script>

<style lang="scss" scoped>
.user_overview {
  display: flex;
  height: 100%;
  width: 100%;
  justify-content:space-evenly;
  align-items: center;

  div {
    // flex: 1;
    width: 100px;

    p {
      text-align: center;
      margin: 5px 0;
      height: 16px;
      font-size: 10px;
    }

    .user_overview_nums {
      width: 90px;
      height: 90px;
      text-align: center;
      line-height: 100px;
      font-size: 10px;
      margin: auto auto;
      background-size: cover;
      background-position: center center;
      position: relative;

      &::before {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        font-size: 5px;
        background-size: cover;
      }

      &.bgdonghua::before {
        animation: rotating 14s linear infinite;
      }
    }

    .allnum {
      // background-image: url("../../assets/img/left_top_lan.png");
      &::before {
        background-image: url("../../../assets/images/left_top_lan.png");
      }
    }

    .online {
      &::before {
        background-image: url("../../../assets/images/left_top_lv.png");
      }
    }

    .offline {
      &::before {
        background-image: url("../../../assets/images/left_top_huang.png");
      }
    }

    .laramnum {
      &::before {
        background-image: url("../../../assets/images/left_top_hong.png");
      }
    }
  }
}
</style>
